<template>
  <div class="">
    <el-table border height="200" v-loading="loading" :data="dataList">
      <el-table-column
        label="办公用电量（kwh）"
        align="center"
        min-width="170"
        prop="officialElectricValue"
        show-overflow-tooltip
      >
        <template slot-scope="scope">
          {{ scope.row.officialElectricValue| numDealfilters}}
        </template>
      </el-table-column>
      <el-table-column
        label="非办公用电量（kwh）"
        align="center"
        width="180"
        prop="nonOfficialElectricValue"
        show-overflow-tooltip
      >
        <template slot-scope="scope">
          {{ scope.row.nonOfficialElectricValue | numDealfilters }}
        </template>
      </el-table-column>
      <el-table-column
        label="特殊用电量（kwh）"
        align="center"
        width="160"
        prop="specialElectricValue"
        show-overflow-tooltip
      >
        <template slot-scope="scope">
          {{ scope.row.specialElectricValue | numDealfilters }}
        </template>
      </el-table-column>
      <el-table-column
        label="用水量（t）"
        align="center"
        width="150"
        prop="energyWater"
        show-overflow-tooltip
      >
        <template slot-scope="scope">
          {{ scope.row.energyWater | numDealfilters }}
        </template>
      </el-table-column>
      <el-table-column
        label="用电量（kwh）"
        align="center"
        width="150"
        prop="energyElectricity"
        show-overflow-tooltip
      >
        <template slot-scope="scope">
          {{ scope.row.energyElectricity | numDealfilters }}
        </template>
      </el-table-column>
      <el-table-column
        label="碳排（kgCO2）"
        align="center"
        width="150"
        prop="carbonEmission"
        show-overflow-tooltip
      >
        <template slot-scope="scope">
          {{ scope.row.carbonEmission | numDealfilters }}
        </template>
      </el-table-column>
      <el-table-column
        label="预算（元）"
        align="center"
        width="150"
        prop="budgetFund"
        show-overflow-tooltip
      >
        <template slot-scope="scope">
          {{ scope.row.budgetFund | numDealfilters }}
        </template>
      </el-table-column>
      <el-table-column
        label="消费统计（元）"
        align="center"
        width="150"
        prop="totalFee"
        show-overflow-tooltip
      >
        <template slot-scope="scope">
          {{ scope.row.totalFee | numDealfilters }}
        </template>
      </el-table-column>
      <el-table-column
        label="结余（元）"
        align="center"
        width="150"
        prop="balance"
        show-overflow-tooltip
      >
        <template slot-scope="scope">
          {{ scope.row.balance | numDealfilters }}
        </template>
      </el-table-column>
      <!-- <el-table-column
        prop="year"
        label="年份"
        align="center"
        width="80"
        show-overflow-tooltip
      >
      </el-table-column>

      <el-table-column
        label="单位面积综合能耗（kgce/m2）"
        align="center"
        width="240"
        prop="unitBuildingAreaEnergyConsumption"
        show-overflow-tooltip
      >
        <template slot-scope="scope">
          {{ scope.row.unitBuildingAreaEnergyConsumption.toFixed(2) }}
        </template>
      </el-table-column>

      <el-table-column
        label="人均水耗（t/p）"
        align="center"
        width="150"
        prop="perCapitaWaterConsumption"
        show-overflow-tooltip
      >
        <template slot-scope="scope">
          {{ scope.row.perCapitaWaterConsumption.toFixed(2) }}
        </template>
      </el-table-column>
      <el-table-column
        label="人均能耗（kgce/p）"
        align="center"
        width="160"
        prop="perCapitaEnergyConsumption"
        show-overflow-tooltip
      >
        <template slot-scope="scope">
          {{ scope.row.perCapitaEnergyConsumption.toFixed(2) }}
        </template>
      </el-table-column>
      <el-table-column
        label="人均碳排（kgCO2/p）"
        align="center"
        width="150"
        prop="perCapitaCarbonEmissions"
        show-overflow-tooltip
      >
        <template slot-scope="scope">
          {{ scope.row.perCapitaCarbonEmissions.toFixed(2) }}
        </template>
      </el-table-column> -->
    </el-table>
  </div>
</template>

  <script>
import { getSummary } from "@/api/general/index.js";
import {dealElectricity} from "@/utils";
export default {
  filters: {
    numDealfilters(num) {
      if (null != num) {
        return dealElectricity(num, 1, 2);
      } else {
        return "";
      }
    }
  },
  components: {},
  props: {
    year: {
      type: [String, Number],
      default: 2024,
    },
  },
  data() {
    return {
      dataList: [],
      loading: false,
    };
  },
  created() {},
  mounted() {},
  watch: {
    year: {
      handler(val) {
        if (val) {
          this.requestYearlist();
        }
      },
      deep: false,
      immediate: true,
    },
  },
  methods: {
    // 年度统计
    requestYearlist() {
      let query = {
        year: this.year,
        pageSize: 1,
      };
      query.deptIds = [this.$store.state.user.deptId];
      getSummary(query)
        .then((res) => {
          if (res.code === 700) {
            this.$message.warning(res.msg);
            return false;
          }
          // console.log(res, "tabledata");
          this.dataList = res?.rows ?? [];
        })
        .catch(() => {
          // this.$message.error("系统错误,请联系管理员!");
        });
    },
  },
};
</script>

  <style lang="scss" scoped></style>
